package net.yuyoo.uusession.core;

import java.io.InputStream;
import java.net.URL;
import java.util.Map;

import net.yuyoo.uusession.support.JsonUtil;
import net.yuyoo.uusession.support.ReloadableProperties;

/**
 * 统一会话配置类
 * @author yuyoo (yuyoo4j@163.com)
 * @teme 2010-6-4 下午03:27:52
 */
public class UUSessionConfig extends ReloadableProperties {
	
	private String config = null;
	
	public UUSessionConfig(String configPath) {
		this.config = configPath;
	}

	@Override
	protected URL getSourceURL() {
		return UUSessionConfig.class.getResource(this.config);
	}

	@SuppressWarnings("unchecked")
	@Override
	protected Map reload(InputStream in, Map tarStorage) { 
		 
		try {
			return JsonUtil.getMapper().readValue(in, Map.class);
		} catch (Exception ex) { 
			throw new IllegalArgumentException("统一会话配置类读取配置信息(json string)异常", ex);
		} 
	}

}
